<template>
	<view class="content">
		<view v-if="content">
			<view class="news-title">{{title}}</view>
			<image class="news-img" :src="newsImage" mode="aspectFill" />
			<u-parse :html="content"></u-parse>
		</view>
		<mescroll-empty v-else></mescroll-empty>
	</view>
</template>


<script>
	import MescrollEmpty from '@/uni_modules/mescroll-uni/components/mescroll-empty/mescroll-empty.vue';
	import parse from '@/uni_modules/uview-ui/components/u-parse/u-parse.vue'
	export default {
		data() {
			return {
				title: "",
				content: "",
				newsImage: ""
			}
		},
		onLoad(options) {
			options.id && this.getDetails(options.id);
		},
		components: {
			MescrollEmpty,
			parse
		},
		methods: {
			async getDetails(id) {
				let res = await uniCloud.callFunction({
					name: 'newsDetails',
					data: {
						id: id
					}
				});
				console.log(res);
				const data = res.result.data;
				if (data.length) {
					this.title = data[0].title;
					this.content = data[0].content;
					console.log(this.content)
					this.newsImage = data[0].cover.url;
				}
			}
		}
	}
</script>

<style lang="scss" scope>
	.content {
		padding: 30rpx;
		color: $u-content-color;
		font-size: 32rpx;
		line-height: 1.8;
	}
</style>